import itertools

# # 将五个人编号为0、1、2、3、4
nationality=['英国','瑞典','丹麦','挪威','德国']
colors=['红','绿','白','黄','蓝']
drinks=['茶','咖啡','牛奶','啤酒','矿泉水']
cigarette=['pa','d','ble','blu','pr']
pets=['狗','鸟','猫','马','鱼']
pos=-1
for n in itertools.permutations(nationality):
    nt = list(n)
    if nt.index('挪威') == 0:
        for co in itertools.permutations(colors):
            cot = list(co)
            if nt.index('英国') == cot.index('红') and cot.index('绿')+1 == cot.index('白') and abs(nt.index('挪威')- cot.index('蓝')) == 1:
                for d in itertools.permutations(drinks):
                    dt = list(d)
                    if nt.index('丹麦') == dt.index('茶') and cot.index('绿') == dt.index('咖啡') and dt.index('牛奶') == 2:
                        for ci in itertools.permutations(cigarette):
                            cit = list(ci)
                            if cit.index('blu') == dt.index('啤酒') and cot.index('黄') == cit.index('d') and nt.index('德国') == cit.index('pr') and abs(cit.index('ble')- dt.index('矿泉水')) == 1:
                                for p in itertools.permutations(pets):
                                    pt=list(p)
                                    if nt.index('瑞典') == pt.index('狗') and cit.index('pa') == pt.index('鸟') and abs(cit.index('ble')- pt.index('猫')) == 1 and abs(cit.index('d')- pt.index('马')) == 1:
                                        pos=pt.index('鱼')
                                        #输出养鱼人的编号
                                        print('养鱼人的编号:'+str(pos))
                                        print('他的国籍:' + n[pos])
                                        print('他房子的颜色:' + co[pos])
                                        print('他喝的饮料:' + d[pos])
                                        print('他抽的香烟' + ci[pos])
                                        print('他养的宠物' + p[pos])

                                    if pos>-1:
                                        break
                            if pos > -1:
                                break
                    if pos > -1:
                        break
            if pos > -1:
                break
    if pos > -1:
        break
